<html>
<head><meta charset="utf-8"><title>Crazy optimization idea -- skipping the parse tree altogethe · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html">Crazy optimization idea -- skipping the parse tree altogethe</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204204083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204204083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204204083">(Jul 17 2020 at 13:15)</a>:</h4>
<p>We are at the point where parsing takes substantional amount of time. I <em>think</em> the main thing we need a parse tree for is the item tree. </p>
<p>I wonder if we should think about producing it <em>without</em> parse tree at all... It seems approximately feasible to use evented parsing for this purpose, instead of a true syntax tree</p>



<a name="204205763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204205763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204205763">(Jul 17 2020 at 13:31)</a>:</h4>
<p>Can the MBE stuff be disabled? I wonder how much faster parsing would get.</p>



<a name="204205886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204205886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204205886">(Jul 17 2020 at 13:32)</a>:</h4>
<p>I think only by commenting it out</p>



<a name="204206004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204206004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204206004">(Jul 17 2020 at 13:33)</a>:</h4>
<p>But where? :D</p>



<a name="204206024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204206024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204206024">(Jul 17 2020 at 13:33)</a>:</h4>
<p>That I don't know without looking :)</p>



<a name="204206275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204206275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204206275">(Jul 17 2020 at 13:36)</a>:</h4>
<p>Yeah, it's 10s vs. 18s, so not that much of a win</p>



<a name="204206521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204206521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204206521">(Jul 17 2020 at 13:38)</a>:</h4>
<p>OTOH, we don't have that many macros (besides  <code>expect!</code> and <code>match_ast!</code>), so it's still a considerable speedup</p>



<a name="204206586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204206586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204206586">(Jul 17 2020 at 13:39)</a>:</h4>
<p>(I stubbed out <code>mbe_expander::expand_rules</code>)</p>



<a name="204207065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207065">(Jul 17 2020 at 13:43)</a>:</h4>
<p>hm?</p>



<a name="204207075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207075">(Jul 17 2020 at 13:43)</a>:</h4>
<p>It's almost twice as fast?</p>



<a name="204207083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207083">(Jul 17 2020 at 13:43)</a>:</h4>
<p>Yeah, something like that</p>



<a name="204207137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207137">(Jul 17 2020 at 13:44)</a>:</h4>
<p>that feels like very much of a win :D</p>



<a name="204207164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207164">(Jul 17 2020 at 13:44)</a>:</h4>
<p>Meh, not even an order of magnitude :-)</p>



<a name="204207213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207213">(Jul 17 2020 at 13:45)</a>:</h4>
<p>On one hand, according to the argument you often make, skipping bodies would make us less likely to optimize the parser itself</p>



<a name="204207269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207269">(Jul 17 2020 at 13:45)</a>:</h4>
<p>On the other hand, <code>analysis-stats</code> still has to parse the bodies, so it's not like we'd no longer know how slow it is</p>



<a name="204207373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207373">(Jul 17 2020 at 13:46)</a>:</h4>
<p>On the third hand, I think you wanted diagnostics support for files that aren't open, so we'd still need the bodies for that</p>



<a name="204207433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207433">(Jul 17 2020 at 13:46)</a>:</h4>
<p>THe number of files in the current crate is far fewer than the total number of files</p>



<a name="204207454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207454">(Jul 17 2020 at 13:47)</a>:</h4>
<p>Like, bodies in libstd are completely uninteresting</p>



<a name="204207459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204207459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204207459">(Jul 17 2020 at 13:47)</a>:</h4>
<p>Oh, right</p>



<a name="204208864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204208864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204208864">(Jul 17 2020 at 13:59)</a>:</h4>
<p>Filed <a href="https://github.com/rust-analyzer/rust-analyzer/issues/5426">https://github.com/rust-analyzer/rust-analyzer/issues/5426</a> for a small thing, if it makes sense</p>



<a name="204209564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204209564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204209564">(Jul 17 2020 at 14:05)</a>:</h4>
<p>Does the parser have an event-based interface already or does it construct the syntax tree directly?</p>



<a name="204209710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204209710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204209710">(Jul 17 2020 at 14:06)</a>:</h4>
<p>It does have an event-based interface</p>



<a name="204209721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204209721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204209721">(Jul 17 2020 at 14:06)</a>:</h4>
<p>(see TreeSink trait)</p>



<a name="204253192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204253192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204253192">(Jul 17 2020 at 20:14)</a>:</h4>
<p>I'm doing planning for specific support for delayed parsing in rowan/sorbus, so here's a quick question:</p>
<p>Does the syntax tree need to hold on to the string contents of the skipped body (to facilitate parsing it later, on-demand), or is sticking a thunk of "skipped N bytes" enough?</p>



<a name="204253336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204253336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204253336">(Jul 17 2020 at 20:16)</a>:</h4>
<p>I'd love (at a mem-usage level, less so the implementation level <span aria-label="stuck out tongue" class="emoji emoji-1f61d" role="img" title="stuck out tongue">:stuck_out_tongue:</span>) to be able to skip storing these huge unparsed strings, if we can always just refer back to a "whole file" view to do the full parse later</p>



<a name="204253368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204253368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204253368">(Jul 17 2020 at 20:16)</a>:</h4>
<p>Or if there are situations where we know with high probability that we won't need to parse the item bodies later</p>



<a name="204258782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204258782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204258782">(Jul 17 2020 at 21:03)</a>:</h4>
<p>(actually, no, <a href="https://github.com/CAD97/sorbus/pull/68">the implementation of text-free thunks</a> was a lot simpler than I thought it was going to be.)</p>



<a name="204258914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204258914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204258914">(Jul 17 2020 at 21:04)</a>:</h4>
<p>It does have cost, though, so I definitely don't want to merge it unless r-a has a chance of using it.</p>



<a name="204259084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204259084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204259084">(Jul 17 2020 at 21:05)</a>:</h4>
<p>I think "tree is a value" is a very valuable design choice.</p>



<a name="204259150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204259150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204259150">(Jul 17 2020 at 21:06)</a>:</h4>
<p>So, I'd say sorbus should store just <code>Box&lt;FnOnce() -&gt; GreenNode&gt;</code> as a thunk</p>



<a name="204259175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204259175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204259175">(Jul 17 2020 at 21:06)</a>:</h4>
<p>THat way, client can store text, store tokens, remmeber the context like edition, etc</p>



<a name="204259872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204259872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204259872">(Jul 17 2020 at 21:13)</a>:</h4>
<p>That does seem optimal, it's just that sticking a <code>Box&lt;dyn FnOnce&gt;</code> into the tree is difficult since its not erasable, and then synchronization issues as well</p>



<a name="204260107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204260107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204260107">(Jul 17 2020 at 21:15)</a>:</h4>
<p>As far as I can tell so far it's not possible for sorbus (as currently architectured) to do an <code>ArcSwap</code>-like trick to mostly transparently swap out a thunk for a real value</p>
<p>Why? Because we're doing pointer un/erasure (on unsized types) and pointer mangling, which is definitely _not_ synchronized</p>



<a name="204260376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Crazy%20optimization%20idea%20--%20skipping%20the%20parse%20tree%20altogethe/near/204260376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Crazy.20optimization.20idea.20--.20skipping.20the.20parse.20tree.20altogethe.html#204260376">(Jul 17 2020 at 21:17)</a>:</h4>
<p>We can just stick in an extra layer of indirection, but <code>Box&lt;Box&lt;dyn Fn&gt;&gt;</code> feels wrong for a reasonable reason</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>